package com.yuma.function4;

import java.util.UUID;
import java.util.function.Supplier;
import java.util.stream.Stream;

public class SupplierDemo {
    public static void main(String[] args) {
        // 不接收参数，给一个返回值
        Supplier<String> s1 = new Supplier<String>() {
            @Override
            public String get() {
                // 产生一个随机数
                return UUID.randomUUID().toString();
            }
        };
        System.out.println(s1.get());

        Supplier<String> s2 = () -> UUID.randomUUID().toString();
        System.out.println(s2.get());

        //Supplier<? extends T>   上限符号 T类已经T的子类
        Stream<String> generate = Stream.generate(s2);
        generate.forEach(s -> System.out.println(s));
    }
}
